package thread;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 * Thead提供了一个静态方法:
 * static void sleep(long )
 */
public class SleepDemo {
    public static void main(String[] args) throws IOException {
        System.out.println("程序开始了");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字:");

        BufferedReader br = new BufferedReader(
                new InputStreamReader(
                        System.in  //低级流,从控制台上读取内容
                )
        );
        String line = br.readLine();//读取一行字符串
        int num = Integer.parseInt(line);//将字符串转换为整数
        for (; num >= 0 ; num--) {
            try {
                System.out.println(num);
                Thread.sleep(1000);//主线程执行时间会阻塞1秒
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("时间到");
        System.out.println("程序结束");


    }
}
